"""
@个人中心API
"""
import logging
from flask import request, Blueprint
from base.tools.develop_tools import JsonResult
from service.api import API

blueprint = Blueprint("game_manager_service", __name__,
                      url_prefix="/game_manager_service/")
logger = logging.getLogger("game_manager_service")


@blueprint.route("/get_game_info", methods=["GET"])
def get_game_info():
    try:
        api_obj = GameManagerAPI()
        res = api_obj.get_game_info()
        return JsonResult.ok("获取游戏信息成功!", res)
    except Exception as e:
        logger.exception(f"获取游戏信息失败!{str(e)}")
        return JsonResult.error("获取游戏信息失败!")


class GameManagerAPI(API):
    def __init__(self) -> None:
        super().__init__()
        self.__table = self._mongo["game_info"]

    def get_game_info(self):
        res = list(self.__table.find(
            {}, {"_id": 0}
        ))

        return res
